Update nuke_format so that it's safe (enough) to handle the bulk deletion
authorRobert Lipe <robertlipe@gmail.com>
Thu, 9 Dec 2021 06:59:15 +0000 (01:59 -0500)
committerRobert Lipe <robertlipe@gmail.com>
Thu, 9 Dec 2021 06:59:15 +0000 (01:59 -0500)
to get rid of most of our older and unused formats. Some hand tuning may
still be needed

tools/nuke_format
tools/reset_nuke [new file with mode: 0755]

index d492a4c128569afd849fd51d80f560e00d674e6a..362d9ea567d096df0d3a155df53e25b131c41927 100755 (executable)
@@ -1,12 +1,17 @@
 # usage nuke_format format_name
 
 SED=$(which gsed)
-EDITOR="${EDITOR:-vim}" 
+EDITOR="${EDITOR:-vim}"
+
+# $1 = format $2 = file in all functions
+
 
-# $1 = format $2 = file
 remove_word() {
 #  git add $2
-  $SED -i "s/$1//g" $2
+set -x
+  # This uses a GNU extension ? for zero or more, letting us match with last
+  # entry in a line which has no following whitespace
+  $SED -i "s/$1\s*//g" $2
 }
 
 remove_line_containing() {
@@ -27,14 +32,17 @@ remove_word $1.h GPSBabel.pro
 
 remove_manually $1 reference/help.txt
 
-remove_line_containing $1 reference/format0.txt
-remove_line_containing $1 reference/format1.txt
-remove_line_containing $1 reference/format2.txt
-remove_manually $1 reference/format3.txt
+# Take out the boilerplate entries in vecs.h ...
 remove_line_containing extern.*$1 vecs.h
 remove_line_containing Format.*$1 vecs.h
 remove_line_containing include.*$1 vecs.h
-remove_manually $1 reference/format3.txt
+# ... then let a human nerd snip3 the actual table entry awy
+remove_manually $1 vecs.h
+
+remove_line_containing $1 reference/format0.txt
+remove_line_containing $1 reference/format1.txt
+remove_line_containing $1 reference/format2.txt
+# This breaks these, but at least it leaves a clue in version history.
 remove_line_containing $1 msvc/GPSBabel.vcxproj
 remove_line_containing $1 msvc/GPSBabel.vcxproj.filters
 
@@ -42,7 +50,7 @@ git rm -f reference/$1*
 git rm -f xmldoc/formats/$1.xml
 git rm -f xmldoc/formats/options/$1.xml
 git rm -f testo.d/$1.test
-git rm -f $1.cc
-git rm -f $1.h
+git mv $1.cc deprecated/
+git mv $1.h deprecated/
 
 # make && ./testo
diff --git a/tools/reset_nuke b/tools/reset_nuke
new file mode 100755 (executable)
index 0000000..2080fc0
--- /dev/null
@@ -0,0 +1,30 @@
+# Temporary script to undo what
+
+rm reference/format?.txt reference/help.txt
+# git rm  reference/format?.txt reference/help.txt
+git reset  reference/format?.txt reference/help.txt
+git checkout reference/format0.txt
+git checkout reference/format1.txt
+git checkout reference/format2.txt
+git checkout reference/format3.txt reference/help.txt
+
+rm GPSBabel.pro vecs.h vecs.cc
+# git rm GPSBabel.pro vecs.h
+#git reset GPSBabel.pro
+#git reset vecs.h
+git checkout GPSBabel.pro vecs.h vecs.cc
+
+# This part of the code devalues almot immediately once pushed upstream
+echo "Now re-killing formats to exercise the script. ^C to cancel. <enter> to ontinue"
+read x
+
+for f in  compegps cst destinator g7to2in gopal gpsutil jtr maggeo mapsend nm4 pcx pocketfms skyforce stmsdf stmwpp tiger vpl wfff yahoo
+do
+  git checkout $f.cc $f.h
+  tools/nuke_format  $f
+done
+
+# nuke_format is also believed to work on:
+# gpsutil destinator exif gopal gpsutil jogmap jtr maggeo
+# mapsend pcx skyforce stmsdf stmwpp tiger vidaone vpl yahoo
+